using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SM64DSe
{
    public class NitroFile : INitroROMBlock
    {
        public NitroFile() { }

        public NitroFile(string filepath)
        {
           // if (id >= 0xF000)
           //     throw new Exception("NitroFile: invalid file ID");

           // m_ROM = rom;
           // m_ID = id;
            System.IO.FileInfo t = new System.IO.FileInfo(filepath);
            m_Name = t.Name;
            m_Data = System.IO.File.ReadAllBytes(filepath);
            path = filepath;
            if (libWiiSharp.Lz77.IsLz77Compressed(m_Data))
                LZ77.Decompress(ref m_Data);
        }

        public virtual void SaveChanges()
        {
            // TODO: LZ77 recompression!

            //m_ROM.ReinsertFile(m_ID, m_Data);
            System.IO.File.WriteAllBytes(path, m_Data);
        }

        public string path;
        public ushort m_ID;
        public string m_Name;
    }
}
